
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>7.3 docker-compose参数介绍 · 《Docker从入门到放弃》</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="杨文成 <cheng2guen@163.com>">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="7.2 docker-compose安装.html" />
    

    
        <link rel="shortcut icon" href="docker.ico" type="image/x-icon">
    
    
    
    
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="docker.ico">
    
    
        
    
    
        
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    第1章 Docker Engine
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../第1章 Docker Engine/1.1 centos安装docker.html">
            
                <a href="../第1章 Docker Engine/1.1 centos安装docker.html">
            
                    
                    1.1 centos安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../第1章 Docker Engine/1.2 ubuntu安装docker.html">
            
                <a href="../第1章 Docker Engine/1.2 ubuntu安装docker.html">
            
                    
                    1.2 ubuntu安装docker
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    第2章 Docker Image
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../第2章 Docker Image/2.1 镜像的基础命令.html">
            
                <a href="../第2章 Docker Image/2.1 镜像的基础命令.html">
            
                    
                    2.1 镜像的基础命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../第2章 Docker Image/2.2 镜像的导出导入.html">
            
                <a href="../第2章 Docker Image/2.2 镜像的导出导入.html">
            
                    
                    2.2 镜像的导出导入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    第3章 Docker Container
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../第3章 Docker Container/3.1 容器的基础命令.html">
            
                <a href="../第3章 Docker Container/3.1 容器的基础命令.html">
            
                    
                    3.1 容器的基础命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../第3章 Docker Container/3.2 部署centos容器.html">
            
                <a href="../第3章 Docker Container/3.2 部署centos容器.html">
            
                    
                    3.2 部署centos容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../第3章 Docker Container/3.3 容器的提交.html">
            
                <a href="../第3章 Docker Container/3.3 容器的提交.html">
            
                    
                    3.3 容器的提交
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../第3章 Docker Container/3.4 容器的导出导入.html">
            
                <a href="../第3章 Docker Container/3.4 容器的导出导入.html">
            
                    
                    3.4 容器的导出导入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    第4章 Docker Volume
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../第4章 Docker Volume/4.1 volume简介.html">
            
                <a href="../第4章 Docker Volume/4.1 volume简介.html">
            
                    
                    4.1 volume简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../第4章 Docker Volume/4.2 数据卷挂载.html">
            
                <a href="../第4章 Docker Volume/4.2 数据卷挂载.html">
            
                    
                    4.2 数据卷挂载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../第4章 Docker Volume/4.3 文件目录挂载.html">
            
                <a href="../第4章 Docker Volume/4.3 文件目录挂载.html">
            
                    
                    4.3 文件目录挂载
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    第5章 Docker Network
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../第5章 Docker Network/5.1 docker网络简介.html">
            
                <a href="../第5章 Docker Network/5.1 docker网络简介.html">
            
                    
                    5.1 docker网络简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../第5章 Docker Network/5.2 docker网络命令.html">
            
                <a href="../第5章 Docker Network/5.2 docker网络命令.html">
            
                    
                    5.2 docker网络命令
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    第6章 Dockerfile
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../第6章 Dockerfile/6.1 Dockerfile参数介绍.html">
            
                <a href="../第6章 Dockerfile/6.1 Dockerfile参数介绍.html">
            
                    
                    6.1 Dockerfile参数介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../第6章 Dockerfile/6.2 构建centos镜像.html">
            
                <a href="../第6章 Dockerfile/6.2 构建centos镜像.html">
            
                    
                    6.2 构建centos镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../第6章 Dockerfile/6.3 构建ubuntu镜像.html">
            
                <a href="../第6章 Dockerfile/6.3 构建ubuntu镜像.html">
            
                    
                    6.3 构建ubuntu镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../第6章 Dockerfile/6.4 构建springboot镜像.html">
            
                <a href="../第6章 Dockerfile/6.4 构建springboot镜像.html">
            
                    
                    6.4 构建springboot镜像
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" >
            
                <span>
            
                    
                    第7章 Docker Compose
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="7.1 docker-compose简介.html">
            
                <a href="7.1 docker-compose简介.html">
            
                    
                    7.1 docker-compose简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="7.2 docker-compose安装.html">
            
                <a href="7.2 docker-compose安装.html">
            
                    
                    7.2 docker-compose安装
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.8.3" data-path="7.3 docker-compose参数介绍.html">
            
                <a href="7.3 docker-compose参数介绍.html">
            
                    
                    7.3 docker-compose参数介绍
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" >
            
                <span>
            
                    
                    第8章 Docker Registry
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../第8章 Docker Registry/8.1 注册DockerHub.html">
            
                <a href="../第8章 Docker Registry/8.1 注册DockerHub.html">
            
                    
                    8.1 注册DockerHub
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../第8章 Docker Registry/8.2 搭建Registry.html">
            
                <a href="../第8章 Docker Registry/8.2 搭建Registry.html">
            
                    
                    8.2 搭建Registry
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../第8章 Docker Registry/8.3 搭建Harbor.html">
            
                <a href="../第8章 Docker Registry/8.3 搭建Harbor.html">
            
                    
                    8.3 搭建Harbor
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" >
            
                <span>
            
                    
                    第9章 Docker Software
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../第9章 Docker Software/9.1 部署Nginx.html">
            
                <a href="../第9章 Docker Software/9.1 部署Nginx.html">
            
                    
                    9.1 部署Nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../第9章 Docker Software/9.2 部署MySQL.html">
            
                <a href="../第9章 Docker Software/9.2 部署MySQL.html">
            
                    
                    9.2 部署MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../第9章 Docker Software/9.3 部署Redis.html">
            
                <a href="../第9章 Docker Software/9.3 部署Redis.html">
            
                    
                    9.3 部署Redis
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" >
            
                <span>
            
                    
                    第10章 Docker Manager
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../第10章 Docker Manager/10.1 portainer.html">
            
                <a href="../第10章 Docker Manager/10.1 portainer.html">
            
                    
                    10.1 portainer
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >7.3 docker-compose参数介绍</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h6 id="docker-compose&#x5E38;&#x7528;&#x5B57;&#x6BB5;&#x4ECB;&#x7ECD;">docker-compose&#x5E38;&#x7528;&#x5B57;&#x6BB5;&#x4ECB;&#x7ECD;</h6>
<table>
<thead>
<tr>
<th>&#x5B57;&#x6BB5;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>build</td>
<td>&#x6307;&#x5B9A;Dockerfile&#x6587;&#x4EF6;&#x540D;&#xFF08;&#x8981;&#x6307;&#x5B9A;&#x7684;Dockerfile&#x6587;&#x4EF6;&#x9700;&#x8981;&#x5728;build&#x6807;&#x7B7E;&#x7684;&#x5B50;&#x7EA7;&#x6807;&#x7B7E;&#x4E2D;&#x7528;dockerfile&#x6807;&#x7B7E;&#x6307;&#x5B9A;&#xFF09;</td>
</tr>
<tr>
<td>dockerfile</td>
<td>&#x6784;&#x5EFA;&#x955C;&#x50CF;&#x4E0A;&#x4E0B;&#x6587;&#x8DEF;&#x5F84;</td>
</tr>
<tr>
<td>context</td>
<td>&#x53EF;&#x4EE5;&#x662F;dockerfile&#x8DEF;&#x5F84;&#xFF0C;&#x6216;&#x8005;&#x662F;&#x6267;&#x884C;git &#x4ED3;&#x5E93;&#x7684;url&#x5730;&#x5740;</td>
</tr>
<tr>
<td>image</td>
<td>&#x6307;&#x5B9A;&#x955C;&#x50CF;&#xFF08;&#x5DF2;&#x5B58;&#x5728;&#xFF09;</td>
</tr>
<tr>
<td>command</td>
<td>&#x6267;&#x884C;&#x547D;&#x4EE4;&#xFF0C;&#x4F1A;&#x8986;&#x76D6;&#x5BB9;&#x5668;&#x542F;&#x52A8;&#x540E;&#x9ED8;&#x8BA4;&#x6267;&#x884C;&#x7684;&#x547D;&#x4EE4;&#xFF08;&#x4F1A;&#x8986;&#x76D6;Dockerfile&#x7684;CMD&#x6307;&#x4EE4;&#xFF09;</td>
</tr>
<tr>
<td>container_name</td>
<td>&#x6307;&#x5B9A;&#x5BB9;&#x5668;&#x540D;&#x79F0;&#xFF0C;&#x7531;&#x4E8E;&#x5BB9;&#x5668;&#x540D;&#x79F0;&#x662F;&#x552F;&#x4E00;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x6307;&#x5B9A;&#x81EA;&#x5B9A;&#x4E49;&#x540D;&#x79F0;&#xFF0C;&#x5219;&#x65E0;&#x6CD5;scale&#x6307;&#x5B9A;&#x5BB9;&#x5668;&#x6570;&#x91CF;</td>
</tr>
<tr>
<td>deploy</td>
<td>&#x6307;&#x5B9A;&#x90E8;&#x7F72;&#x548C;&#x8FD0;&#x884C;&#x670D;&#x52A1;&#x76F8;&#x5173;&#x914D;&#x7F6E;&#xFF0C;&#x53EA;&#x80FD;&#x5728;Swarm&#x6A21;&#x5F0F;&#x4F7F;&#x7528;</td>
</tr>
<tr>
<td>environment</td>
<td>&#x6DFB;&#x52A0;&#x73AF;&#x5883;&#x53D8;&#x91CF;</td>
</tr>
<tr>
<td>networks</td>
<td>&#x52A0;&#x5165;&#x7F51;&#x7EDC;&#xFF0C;&#x5F15;&#x7528;&#x9876;&#x7EA7;networks&#x4E0B;&#x6761;&#x76EE;</td>
</tr>
<tr>
<td>network-mode</td>
<td>&#x8BBE;&#x7F6E;&#x5BB9;&#x5668;&#x7684;&#x7F51;&#x7EDC;&#x6A21;&#x5F0F;</td>
</tr>
<tr>
<td>ports</td>
<td>&#x66B4;&#x9732;&#x5BB9;&#x5668;&#x7AEF;&#x53E3;&#xFF0C;&#x4E0E;-p &#x76F8;&#x540C;&#xFF0C;&#x4F46;&#x662F;&#x7AEF;&#x53E3;&#x4E0D;&#x80FD;&#x4F4E;&#x4E8E;60</td>
</tr>
<tr>
<td>volumes</td>
<td>&#x6302;&#x8F7D;&#x4E00;&#x4E2A;&#x5BBF;&#x4E3B;&#x673A;&#x76EE;&#x5F55;&#x6216;&#x547D;&#x4EE4;&#x5377;&#x5230;&#x5BB9;&#x5668;&#xFF0C;&#x547D;&#x540D;&#x5377;&#x8981;&#x5728;&#x9876;&#x7EA7;volumes &#x5B9A;&#x4E49;&#x5377;&#x540D;&#x79F0;</td>
</tr>
<tr>
<td>hostname</td>
<td>&#x5728;&#x5BB9;&#x5668;&#x5185;&#x8BBE;&#x7F6E;&#x5185;&#x6838;&#x53C2;&#x6570;</td>
</tr>
<tr>
<td>links</td>
<td>&#x8FDE;&#x63A5;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x5BB9;&#x5668;&#xFF0C;- &#x670D;&#x52A1;&#x540D;&#x79F0;[ : ]</td>
</tr>
<tr>
<td>privileged</td>
<td>&#x7528;&#x6765;&#x7ED9;&#x5BB9;&#x5668;root&#x6743;&#x9650;&#xFF0C;&#x6CE8;&#x610F;&#x662F;&#x4E0D;&#x5B89;&#x5168;&#x7684;&#xFF0C;true</td>
</tr>
<tr>
<td>depends_on</td>
<td>&#x6B64;&#x6807;&#x7B7E;&#x7528;&#x4E8E;&#x89E3;&#x51B3;&#x5BB9;&#x5668;&#x7684;&#x4F9D;&#x8D56;&#xFF0C;&#x542F;&#x52A8;&#x5148;&#x540E;&#x95EE;&#x9898;&#x3002;&#x5982;&#x542F;&#x52A8;&#x5E94;&#x7528;&#x5BB9;&#x5668;&#xFF0C;&#x9700;&#x8981;&#x5148;&#x542F;&#x52A8;&#x6570;&#x636E;&#x5E93;&#x5BB9;&#x5668;</td>
</tr>
<tr>
<td>restart</td>
<td>&#x91CD;&#x542F;&#x7B56;&#x7565;&#xFF1A;&#x5B9A;&#x4E49;&#x662F;&#x5426;&#x91CD;&#x542F;&#x5BB9;&#x5668;&#xFF1B;1.no&#xFF0C;&#x9ED8;&#x8BA4;&#x7B56;&#x7565;&#xFF0C;&#x5728;&#x5BB9;&#x5668;&#x9000;&#x51FA;&#x65F6;&#x4E0D;&#x91CD;&#x542F;&#x5BB9;&#x5668;&#x3002;2.on-failure&#xFF0C;&#x5728;&#x5BB9;&#x5668;&#x975E;&#x6B63;&#x5E38;&#x9000;&#x51FA;&#x65F6;&#xFF08;&#x9000;&#x51FA;&#x72B6;&#x6001;&#x975E;0&#xFF09;&#xFF0C;&#x624D;&#x4F1A;&#x91CD;&#x542F;&#x5BB9;&#x5668;&#x3002;3.on-failure&#xFF1A;3&#xFF0C;&#x5728;&#x5BB9;&#x5668;&#x975E;&#x6B63;&#x5E38;&#x9000;&#x51FA;&#x65F6;&#x91CD;&#x542F;&#x5BB9;&#x5668;&#xFF0C;&#x6700;&#x591A;&#x91CD;&#x542F;3&#x6B21;&#x3002;4.always&#xFF0C;&#x5728;&#x5BB9;&#x5668;&#x9000;&#x51FA;&#x65F6;&#x603B;&#x662F;&#x91CD;&#x542F;&#x5BB9;&#x5668;&#x3002;5.unless-stopped&#xFF0C;&#x5728;&#x5BB9;&#x5668;&#x9000;&#x51FA;&#x65F6;&#x603B;&#x662F;&#x91CD;&#x542F;&#x5BB9;&#x5668;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x8003;&#x8651;&#x5728;Docker&#x5B88;&#x62A4;&#x8FDB;&#x7A0B;&#x542F;&#x52A8;&#x65F6;&#x5C31;&#x5DF2;&#x7ECF;&#x505C;&#x6B62;&#x4E86;&#x7684;&#x5BB9;&#x5668;</td>
</tr>
</tbody>
</table>
<h6 id="&#x7F16;&#x5199;docker-composeyml">&#x7F16;&#x5199;docker-compose.yml</h6>
<pre><code class="lang-yaml"><span class="hljs-attr">version:</span> <span class="hljs-string">&apos;3&apos;</span>
<span class="hljs-attr">services:</span>

<span class="hljs-attr">  api:</span>                                         <span class="hljs-comment"># &#x670D;&#x52A1;&#x540D;&#x79F0;</span>
<span class="hljs-attr">      build:</span>
<span class="hljs-attr">        context:</span> .                            <span class="hljs-comment"># Dockerfile&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</span>
<span class="hljs-attr">        dockerfile:</span> Dockerfile                <span class="hljs-comment"># Dockerfile&#x6587;&#x4EF6;&#x540D;</span>
<span class="hljs-attr">    image:</span> java:dockerfile                  <span class="hljs-comment"># &#x955C;&#x50CF;&#x540D;&#x79F0;(&#x6765;&#x81EA;&#x4E8E;dockerfile&#x6784;&#x5EFA;)</span>
<span class="hljs-attr">    container_name:</span> admin_container          <span class="hljs-comment"># &#x5BB9;&#x5668;&#x540D;&#x79F0;</span>
<span class="hljs-attr">    restart:</span> always                         <span class="hljs-comment"># &#x91CD;&#x542F;&#x7B56;&#x7565;: &#x5F00;&#x673A;&#x81EA;&#x542F;&#x52A8;</span>
<span class="hljs-attr">    privileged:</span> <span class="hljs-literal">true</span>                        <span class="hljs-comment"># &#x62E5;&#x6709;&#x6743;&#x9650;</span>
<span class="hljs-attr">    environment:</span>
<span class="hljs-attr">      TZ:</span> Asia/Shanghai                     <span class="hljs-comment"># &#x6307;&#x5B9A;&#x65F6;&#x533A;</span>
<span class="hljs-attr">    logging:</span>                                <span class="hljs-comment"># &#x5BB9;&#x5668;&#x65E5;&#x5FD7;&#x8BBE;&#x7F6E;</span>
<span class="hljs-attr">      driver:</span> <span class="hljs-string">&quot;json-file&quot;</span>
<span class="hljs-attr">      options:</span>
<span class="hljs-attr">        max-size:</span> <span class="hljs-string">&quot;100m&quot;</span>
<span class="hljs-attr">        max-file:</span> <span class="hljs-string">&quot;3&quot;</span>     
<span class="hljs-attr">    volumes:</span>                                <span class="hljs-comment"># &#x6302;&#x8F7D;&#x6587;&#x4EF6;</span>
<span class="hljs-bullet">      -</span> /etc/localtime:/etc/localtime:ro
<span class="hljs-attr">    ports:</span>                                  <span class="hljs-comment"># &#x6620;&#x5C04;&#x7AEF;&#x53E3;</span>
<span class="hljs-bullet">      -</span> <span class="hljs-number">8010</span>:<span class="hljs-number">8010</span>
<span class="hljs-attr">    command:</span> [                                <span class="hljs-comment"># &#x6267;&#x884C;&#x7684;&#x547D;&#x4EE4;</span>
      <span class="hljs-string">&apos;java&apos;</span>,
      <span class="hljs-string">&apos;-jar&apos;</span>,
      <span class="hljs-string">&apos;/home/api/admin/admin-2.0.jar&apos;</span>  
    ]
</code></pre>
<blockquote>
<p>&#x4E00;&#x822C;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;docker-compose.yml&#x4E3A;&#x9ED8;&#x8BA4;&#x6587;&#x4EF6;&#x540D;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x7528;&#x5176;&#x4ED6;&#x540D;&#x79F0;&#xFF0C;&#x9700;&#x8981;&#x52A0;&#x53C2;&#x6570;-f&#x6307;&#x5B9A;&#xFF1B;</p>
<p>&#x9700;&#x8981;&#x5728;docker-compose.yml&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0B;&#x624D;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x547D;&#x4EE4;&#xFF1B;</p>
</blockquote>
<h6 id="docker-compose&#x7684;&#x5E38;&#x7528;&#x547D;&#x4EE4;">docker-compose&#x7684;&#x5E38;&#x7528;&#x547D;&#x4EE4;</h6>
<pre><code class="lang-bash"><span class="hljs-comment"># &#x521B;&#x5EFA;&#x5E76;&#x542F;&#x52A8;&#x5BB9;&#x5668;</span>
docker-compose up
<span class="hljs-comment"># &#x540E;&#x53F0;&#x542F;&#x52A8;</span>
docker-compose up <span class="hljs-_">-d</span>
<span class="hljs-comment"># &#x540E;&#x53F0;&#x542F;&#x52A8;&#x5E76;&#x6307;&#x5B9A;&#x670D;&#x52A1;</span>
docker-compose up <span class="hljs-_">-d</span> service_name

<span class="hljs-comment"># &#x5173;&#x95ED;&#x5E76;&#x79FB;&#x9664;&#x5BB9;&#x5668;</span>
docker-compose down

<span class="hljs-comment"># &#x5217;&#x51FA;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x7684;&#x5BB9;&#x5668;</span>
docker-compose ps
<span class="hljs-comment"># &#x5217;&#x51FA;&#x6240;&#x6709;&#x5BB9;&#x5668;&#xFF08;&#x5305;&#x62EC;&#x505C;&#x6B62;&#x7684;&#xFF09;</span>
docker-compose ps <span class="hljs-_">-a</span>

<span class="hljs-comment"># &#x505C;&#x6B62;&#x5BB9;&#x5668;</span>
docker-compose stop

<span class="hljs-comment"># &#x5F00;&#x542F;&#x5BB9;&#x5668;</span>
docker-compose start

<span class="hljs-comment"># &#x91CD;&#x542F;&#x5BB9;&#x5668;</span>
docker-compose start

<span class="hljs-comment"># &#x8FDB;&#x5165;&#x5BB9;&#x5668;</span>
docker-compose <span class="hljs-built_in">exec</span> service_name bash

<span class="hljs-comment"># &#x67E5;&#x770B;&#x65E5;&#x5FD7;</span>
<span class="hljs-comment"># docker-compsoe -f: &#x6307;&#x5B9A;&#x6587;&#x4EF6;&#x540D;&#x79F0;&#x4E3A;docker-compose_xxx.yml</span>
<span class="hljs-comment"># -f&#xFF1A;&#x5B9E;&#x65F6;&#x52A8;&#x6001;&#x66F4;&#x65B0;</span>
<span class="hljs-comment"># --tail=200&#xFF1A;&#x663E;&#x793A;&#x672B;&#x5C3E;200&#x884C;</span>
<span class="hljs-comment"># system&#xFF1A;&#x670D;&#x52A1;&#x540D;&#x79F0;</span>
docker-compsoe <span class="hljs-_">-f</span> docker-compose_xxx.yml logs <span class="hljs-_">-f</span> --tail=200 system
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="7.2 docker-compose安装.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 7.2 docker-compose安装">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"7.3 docker-compose参数介绍","level":"1.8.3","depth":2,"next":{"title":"第8章 Docker Registry","level":"1.9","depth":1,"ref":"","articles":[{"title":"8.1 注册DockerHub","level":"1.9.1","depth":2,"path":"第8章 Docker Registry/8.1 注册DockerHub.md","ref":"第8章 Docker Registry/8.1 注册DockerHub.md","articles":[]},{"title":"8.2 搭建Registry","level":"1.9.2","depth":2,"path":"第8章 Docker Registry/8.2 搭建Registry.md","ref":"第8章 Docker Registry/8.2 搭建Registry.md","articles":[]},{"title":"8.3 搭建Harbor","level":"1.9.3","depth":2,"path":"第8章 Docker Registry/8.3 搭建Harbor.md","ref":"第8章 Docker Registry/8.3 搭建Harbor.md","articles":[]}]},"previous":{"title":"7.2 docker-compose安装","level":"1.8.2","depth":2,"path":"第7章 Docker Compose/7.2 docker-compose安装.md","ref":"第7章 Docker Compose/7.2 docker-compose安装.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","search-pro","expandable-chapters","back-to-top-button","code","favicon-absolute","hide-element","insert-logo","donate"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"search-pro":{},"code":{"copyButtons":true},"donate":{"alipay":"https://minio.lyqzhpt.com/typora/alipay.jpg","alipayText":"支付宝","button":"欢迎赞赏","title":"","wechat":"https://minio.lyqzhpt.com/typora/wechatpay.jpg","wechatText":"微信"},"favicon-absolute":{"appleTouchIconMore":{},"appleTouchIconPrecomposed152":"docker.ico","appleTouchIconPrecomposedMore":{},"favicon":"docker.ico"},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"insert-logo":{"style":"background: none; max-height: 32px; min-height: 32px","url":"https://minio.lyqzhpt.com/typora/docker.png"},"expandable-chapters":{}},"theme":"default","author":"杨文成 <cheng2guen@163.com>","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《Docker从入门到放弃》","gitbook":"*","description":"docker常用功能介绍"},"file":{"path":"第7章 Docker Compose/7.3 docker-compose参数介绍.md","mtime":"2023-05-23T01:49:04.048Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-05-23T07:10:58.029Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

